<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">

<div class="container-div">
    <div class="row">
        <div class="col-sm-12 select-info">
            <form id="operlog-form">
                <div class="select-list gd">
                    <ul>

                        <li>
                            <label>申请人(Requestor)：</label>
                            <input name="user.name">
                        </li>
                        <li>
                            申请表状态(Status)：<select name="status"
                        >
                            <option value="">所有</option>
                            <option th:value="1">待审核</option>
                            <option th:value="2">同意申请</option>
                            <option th:value="3">拒绝申请</option>
                            <option th:value="4">放弃申请</option>
                        </select>
                        </li>
                        <li class="select-time">
                            <label>申请时间(Apply Date)： </label>
                            <input type="text" class="time-input" style="width: 150px" id="beginTime" placeholder="开始时间"
                                   name="beginTime" lay-key="1">
                            <span>-</span>
                            <input type="text" class="time-input" style="width: 150px" id="overTime" placeholder="结束时间"
                                   name="overTime" lay-key="2">
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm"
                               onclick="$.table.search($('form').attr('id'))"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm"
                            onclick="$.form.reset($('form').attr('id'))"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group hidden-xs" id="toolbar" role="group">
            <!--<a class="btn btn-outline btn-success btn-rounded" onclick="$.operate.add()"-->
               <!--shiro:hasPermission="leave:add">-->
                <!--<i class="fa fa-plus"></i> 申请-->
            <!--</a>-->
            <!--<a class="btn btn-outline btn-danger btn-rounded" onclick="$.operate.batRemove()"-->
               <!--shiro:hasPermission="leave:del">-->
                <!--<i class="fa fa-trash-o"></i> 删除-->
            <!--</a>-->
            <a class="btn btn-warning" onclick="$.table.exportExcel()"
               shiro:hasPermission="leave:export">
                <i class="fa fa-download"></i> 下载
            </a>
        </div>
        <div class="col-sm-12 select-info order-table">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>

<script th:inline="javascript">
    var prefix = "/leave";
    var updateFlag = [[${@permission.hasPermi('"leave:update')}]];
    var addFlag = [[${@permission.hasPermi('"leave:add')}]];
    $(function () {
        var options = {
            url: prefix + "/TableMyLeaveHiList2",
//            pictureUrl: "/task/flowChart/{id}", //流程图
//            createUrl: "/leave/toAdd",
//            removeUrl: prefix + "/del",
//            updateUrl: "/leave/edit/{id}",
            exportUrl: prefix + "/export",
            sortName: "START_TIME_",  //对应数据库表述中的字段
            sortOrder: "desc",
            modalName: "审批",
            search: false,
            showExport: true,
            columns: [
                {
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '申请编号</br>(number)',
                    align: 'center'
                },
//                {
//                    field: 'procInstId',
//                    title: '实例Id',
//                    visible: true
//                },
//                {
//                    field: 'businessKey',
//                    title: '实例名称',
//                    align: 'center',
//                    formatter: function (value, row, index) {
//                        if (value.indexOf("0") == 0) {
//                            return "会议室申请";
//                        } else {
//                            return "人员借调申请";
//                        }
//                    }
//
//                },
                {
                    field: 'hrUser.englishName',
                    title: '申请人</br>(Requestor)',
                    align: 'center'
//                    formatter:function (value,row) {
//                        return row.user.name;
//                    }
                },
                {
                    field: 'hrUser.supervisorEnName',
                    title: '审批人</br>(Approver)',
                    align: 'center',
                },
                {
                    field: 'hrUser.hrDept',
                    title: '部门</br>(Department)',
                    align: 'center'
                },
                {
                    field: 'hrUser.costCenter',
                    title: '成本中心</br>(CostCenter)',
                    align: 'center'
                },
                {
                    field: 'leave.requestedOne',
                    title: '需求普工数量</br>(Request Normal)',
                    align: 'center'
                },
                {
                    field: 'leave.requestedTwo',
                    title: '需求缝工数量</br>(Request Sewing)',
                    align: 'center'
                },
                {
                    field : 'leave.customer',
                    title : '客户</br>(customer)',
                    align: 'center'
                },
                {
                    field : 'leave.supportingProject',
                    title : '支持项目</br>(Supporting Project)',
                    align: 'center'
                },
                {
                    field : 'leave.totalTime',
                    title : '时间合计/小时</br>(TotalTime/Hour)',
                    align: 'center'
                },
                {
                    field: 'startTime',
                    title: '申请时间</br>(Apply Date)',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return $.common.dateFormat(value)
                    }
                },
                {
                    field: 'endTime',
                    title: '结束时间</br>(Finish Date)',
                    align: 'center',
                    formatter: function (value, row, index) {

                        if (value == null) {
                            return '<span class="badge badge-warning">待审批！</span>';
                        } else {
                            return $.common.dateFormat(value)
                        }
                    }
                },

//                {
//                    field: 'status',
//                    title: '状态',
//                    align: 'center',
//                    formatter: function (value, row, index) {
//                        if (value == '0') {
//                            return '<span class="badge badge-primary">待审核</span>';
//                        } else if (value == '1') {
//                            return '<span class="badge badge-warning">同意申请</span>';
//                        } else if (value == '2'){
//                            return '<span class="badge badge-danger">拒绝申请</span>';
//                        } else if (value == '3'){
//                            return '<span class="badge badge-danger">放弃申请</span>';
//                        }
//                    }
//                },
                {
//                    title: '操作</br>(operate)',
//                    align: 'center',
//                    formatter: function (value, row, index) {
//                        var actions = [];
//                        $.ajaxSettings.async = false;
//                        $.post("/leave/checkAgent", {proceId: row.procInstId}, function (result) {
//                            //onclick="fileDown(\''+row.fileId+'\',\''+row.fileName+'\')"
//                            if (result == "true") {
//                                actions.push('<a class="' + addFlag + 'btn btn-info btn-xs " href="#" onclick="submit(\'' + row.procInstId + '\')"><i class="fa fa-power-off"></i> 提交</a> ');
//                                actions.push('<a class="' + addFlag + 'btn btn-danger btn-xs " href="#" onclick="giveUp(\'' + row.procInstId + '\')"><i class="fa fa-remove"></i> 放弃</a> ');
//                            }
//                            actions.push('<a   class="' + updateFlag + 'btn btn-info btn-xs " href="#" onclick="$.operate.edit(\'' + row.procInstId + '\')"><i class="fa fa-edit"></i> 查看</a> ');
//                            actions.push('<a   class="' + updateFlag + 'btn btn-warning btn-xs " href="#" onclick="ViewProcess(\'' + row.procInstId + '\')"><i class="fa fa-edit"></i> 进程</a> ');
//                            //actions.push('<a  class="' + updateFlag + 'btn btn-success btn-xs " href="#" onclick="$.operate.FlowCharPng(\'' + row.procInstId + '\')"><i class="fa fa-picture-o"></i> 流程图</a>');
//
//                        })
//                        return actions.join('');
//                    }
                }]
        };
        $.table.init(options);
    });


    function ViewProcess(procInstId) {
        $.modal.open("审批流程", "/hiActi/HiProcActiList/" + procInstId);
    }

    function submit(procInstId) {
        if (confirm("确定提交该条信息吗？")) {
        $.ajaxSettings.async = true;
        $.modal.loading("正在处理中，请稍后...");
        $.post("/leave/submit", {
            procInstId: procInstId
        }, function (result) {
            $.operate.ajaxSuccess(result)
        });
        }
    }

    function giveUp(procInstId) {
        if (confirm("确定放弃该条信息吗？")) {
        $.ajaxSettings.async = true;
        $.modal.loading("正在处理中，请稍后...");
        $.post("/leave/giveUp", {
            procInstId: procInstId
        }, function (result) {
            $.operate.ajaxSuccess(result)
        });
        }
    }
    
</script>
</body>
</html>